/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            indexMenuInfo: {
                menus: [],
                total: 0,
                records: 1,
                moreCondition: false,
                hktId: '',
                isShows: [],
                conditions: {
                    ispublic: 'N',
                    hktName: '',
                    isShow: '',
                    shopId: '',
                }
            }
        },
        _initMethod: function () {
            $that._listMenus(DEFAULT_PAGE, DEFAULT_ROWS);
            vc.getDict('housekeeping_type', "is_show", function (_data) {
                $that.indexMenuInfo.isShows = _data;
            });
        },
        _initEvent: function () {
            vc.on('indexMenu', 'listMenu', function (_param) {
                $that._listMenus(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listMenus(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listMenus: function (_page, _rows) {
                $that.indexMenuInfo.conditions.page = _page;
                $that.indexMenuInfo.conditions.row = _rows;
                $that.indexMenuInfo.conditions.shopId =vc.getCurrentCommunity().shopId;
                let param = {
                    params: $that.indexMenuInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/shopMenu.listShopMenu',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.indexMenuInfo.total = _json.total;
                        $that.indexMenuInfo.records = _json.records;
                        $that.indexMenuInfo.menus = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.indexMenuInfo.records,
                            dataCount: $that.indexMenuInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddMenuModal: function () {
                vc.emit('addIndexMenu', 'openAddIndexMenuModal', {});
            },
            _openAddHouseKeepMenuModal: function () {
                vc.emit('addHouseKeepMenu', 'openAddHouseKeepMenuModal', {});
            },
            _openAddServiceMenuModal: function () {
                vc.emit('addServiceMenu', 'openAddServiceMenuModal', {});
            },
            _openAddShopMenuModal: function () {
                vc.emit('addShopMenu', 'openAddShopMenuModal', {});
            },

            _openAddCategoryMenuModal: function () {
                vc.emit('addCategoryMenu', 'openAddCategoryMenuModal', {});
            },
        
            _openEditMenuModel: function (_menu) {
                vc.emit('editIndexMenu', 'openEditIndexMenuModal', _menu);
            },
            _openDeleteMenuModel: function (_menu) {
                vc.emit('deleteIndexMenu', 'openDeleteIndexMenuModal', _menu);
            },
           
            
            //查询
            _queryMenuMethod: function () {
                $that._listMenus(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetMenuMethod: function () {
                $that.indexMenuInfo.conditions.hktName = "";
                $that.indexMenuInfo.conditions.isShow = "";
                $that._listMenus(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.indexMenuInfo.moreCondition) {
                    $that.indexMenuInfo.moreCondition = false;
                } else {
                    $that.indexMenuInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);
